/** mixin */
import { getIotControl, iotLogupdate } from "@/api/bedList";
import Push from 'push.js'
import { ysxShowLogin, ysxShowAreadevice } from "@/api/ysxroom";
import { generateMixed } from "@/utils"
import {
  getAccessToken,
} from "@/utils/accessToken";
import { mapGetters } from "vuex"
const audio1596 = require('../assets/mp3/1596.mp3')
const audio5196 = require('../assets/mp3/5196.mp3')
const audio8069 = require('../assets/mp3/8069.mp3')
const audio10686 = require('../assets/mp3/10686.mp3')
export default {
  data() {
    return{
      websocketList: null,
      lightList: [],
      pageDataList: [],
      scene_list: [],
      area_list: [],
      testdeviceactivename: "",
      dataList: [
        {
          id: 1,
          room_code: "多功能会议室",
        },
        {
          id: 2,
          room_code: "娱乐室1",
        },
        {
          id: 2,
          room_code: "娱乐室2",
        },
        {
          id: 3,
          room_code: "健康管理中心",
        },
        {
          id: 5,
          room_code: "老年人评估中心",
        },
        {
          id: 6,
          room_code: "适老化展示区",
        },
        {
          id: 6,
          room_code: "居家养老",
        },
        
        {
          id: 8,
          room_code: "办公室",
        },
        {
          id: 9,
          room_code: "男女浴室",
        },
      ],
      testlist: [],
      binddeviceList: [],
      audio: null,
      vensiData: {},
      closeTitle: "",
      lightDeviceList: [],
      binddeviceListLight: [],
      toiletList: [],
      sceneList: [],
      roomIndex: 0,
      roomTestIndex: 0,
      bedDeviceList: [],
      bedPageDataList: [],
      pageDataNum: false,
      notifications: {},
      notifiNum: sessionStorage.getItem('notifiNum') || 0,
      ysxBinddeviceList:[],
      jujiaobj: {
        value1: false,
        value2: false,
        value3: false,
        value4: false,
        onoff1: false,
        onoff2: false,
        onoff3: false,
        onoff4: false,
        color: 0,
        laorenmove: 0
      },
      jiehuobj: {
        laorenmove:0,
        color: 0
      },
      quanhuobj: {
        value1: false,
        value2: false,
        onoff1: false,
        onoff2: false,
        color: 0
      },
      zhongzhengobj: {
        value1: 1,
        value2: 0,
        value3: 0
      },
      // webSocket对象        
      webSocket: null,        
      // webSocketUrl地址        
      webSocketUrl: "ws://39.98.179.212:9999",    
      //连贯标识 防止反复连贯        
      isConnect: false,        
      //断线重连后，提早5秒从新创立WebSocket连贯  rec用来存储提早申请的代码        
      rec: null,        
      //每段时间发送一次心跳包 这里设置为20s    
      timeout: 20000,        
      //延时发送音讯对象（启动心跳新建这个对象，收到音讯后重置对象）        
      timeoutObj: null, 
      checkMsg: "发送数据"
    }
  },
  computed: {
    ...mapGetters({
      adminType: "user/type",
      ysxAreaList: "websocket/ysxAreaList",
      ysxSceneList: "websocket/ysxSceneList"
    })
  },
  mounted() {
    if(getAccessToken()){
      getIotControl().then(() => {
        if(typeof(WebSocket) === "undefined"){
          alert("您的浏览器不支持WebSocket")
          return false
        }
        
        this.createWebSocket();
        
        if(this.$route.path == "/testdevice" || this.$route.path == "/ysxRoom") {
          
        }
      })
      this.audio = new Audio();
      this.closeTitle = localStorage.getItem("syonoff") && localStorage.getItem("syonoff") == 'off' ? "打开声音" : "关闭声音";
      //尉氏县网关登录
      ysxShowLogin({host_id: "40aa568e24d5"})
    }
    if(sessionStorage.getItem('notifiNum')) {
      this.notifiNum = Number(sessionStorage.getItem('notifiNum')) || 0;
    } else {
      sessionStorage.setItem('notifiNum', 0)
    }
  },
  created() {
    Push.Permission.request();
  },
  methods: {
    //创立webSocket连贯
    createWebSocket() {    
      let that = this;
      
      try {
        if ("WebSocket" in window) {
          that.webSocket = new WebSocket(that.webSocketUrl);
        } else if ("MozWebSocket" in window) {
          that.webSocket = new MozWebSocket(that.webSocketUrl);
        }
        that.initWebsocket();
      } catch (e) {
        that.reConnect(that.webSocketUrl);
      }
      
    },
    //初始化webSocket连贯
    initWebsocket() {    
      let that = this;    
      //WebSocket连贯建设之后会调用onopen办法
      that.webSocket.onopen = that.websocketonopen;    
      //当websocket收到服务器发送的信息之后  会调用onmessage办法     
      that.webSocket.onmessage = that.websocketonmessage;
      //当websocket因为各种起因（失常或者异样）敞开之后，会调用onclose办法    
      that.webSocket.onclose = that.websocketclose;    
      //当websocket因为异样起因（比方服务器部署、断网等）敞开之后，会调用onerror办法    
      //在onerror中须要调用reConnect办法重连服务器    
      that.webSocket.onerror = that.websocketonerror;
    },
    //打开
    websocketonopen() {    
      let that = this;    
      console.log('websocket重新连接了') 
      //连贯建设后批改标识    
      that.isConnect = true;    
      // 建设连贯后开始心跳    
      // 因为nginx个别会设置例如60s没有传输数据就断开连接  所以要定时发送数据    
      // that.timeoutObj = setTimeout(function() {        
      //     if (that.isConnect) that.webSocket.send(that.checkMsg);    
      // }, that.timeout);
    },
    websocketonerror() {    
      let that = this;    
      console.log("websocket服务出错了---onerror");   
      //连贯断开后批改标识    
      that.isConnect = false;    
      //连贯谬误 须要重连    
      that.reConnect();
    },
    websocketonmessage(e) {    
      // 拿到数据，解决本人的业务    
      let that = this;    
      //获取音讯后 重置心跳    
      that.init(e, that);
      // clearTimeout(that.timeoutObj);    
      // that.timeoutObj = setTimeout(function() {    
      //     if (that.isConnect) that.webSocket.send(that.checkMsg);    
      // }, that.timeout);
    },
    websocketclose() {    
      let that = this;    
      console.log("websocket服务关闭了+++onclose"); 
      //连贯断开后批改标识    
      that.isConnect = false;    
      //连贯谬误 须要重连    
      that.reConnect();
    },
    reConnect() {    
      let that = this;    
      console.log('尝试从新连贯');    
      //如果曾经连上就不在重连了    
      if (that.isConnect) {        
          return;    
      }    
      clearTimeout(that.rec);    
      // 提早5秒重连  防止过屡次过频繁申请重连    
      that.rec = setTimeout(function() {    
          that.createWebSocket();    
      }, 5000);
    },
    //关闭单个通知
    closeNotification(id) {
      this.notifications[id].close();
      delete this.notifications[id];
    },
    //关闭所有通知
    closeAllNotification(){
      this.$notify.closeAll()
    },
    //打开一个新的通知
    openMessageTips(message, callback){
      let _this = this;
      let notify = this.$notify({
        title: message.title,
        type: 'warning',
        customClass: "notificiation-wrap",
        showClose: false,
        duration: 0,
        offset: 140,
        dangerouslyUseHTMLString: true,
        message: this.$createElement('div', null,
          [
            this.$createElement('div', null, [this.$createElement('span', null, message.message)]),
            this.$createElement('div', null,
              [
                this.$createElement(
                  'button',
                  {
                    style: {
                      padding: '9px 15px',
                      textAlign: 'center',
                      textDecoration: 'none',
                      float: "right",
                      display: 'inline-block',
                      webkitTransitionDuration: '0.4s',
                      transitionDuration: '0.4s',
                      cursor: 'pointer',
                      backgroundColor: '#1890ff',
                      color: '#ffffff',
                      border: '1px solid #1890ff',
                      borderRadius: '2px',
                      fontSize: '12px'
                    },
                    on: {
                      mouseout: function(e) {
                        e.target.style.backgroundColor = '#1890ff';
                      },
                      mouseover: function(e) {
                        e.target.style.backgroundColor = '#46a6ff';
                      },
                      click: function() {
                        _this.closeNotification(message.messageId)
                        callback && callback()
                      }
                    }
                  },
                  "处理"
                )
              ]
            )
          ]
        ),
        duration: 0,
      });
      //将messageId和通知实例放入字典中
      this.notifications[message.messageId] = notify;
    },
    handleClosesy() {
      if(localStorage.getItem("syonoff") == 'on') {
        localStorage.setItem("syonoff", 'off')
        this.closeTitle = "打开声音"
      } else {
        localStorage.setItem("syonoff", 'on')
        this.closeTitle = "关闭声音"
      }
    },
    toGB2312(str) {
      return unescape(str.replace(/u/gi, '\\u').replace(/\\u/gi, '%u'));
    },
    init(res, _that) {
      // const _that = this;
      let data = eval("(" + res.data + ")");
        if(!data){
          return false
        }
        if(data.type == 2) {
          data.data.map(item => {
            let location = "";
            if(data.push_address == 'show_area') {
              if(item.devID == "5C0272FFFEA7CF8401") {
                location = "请注意查看，居家自理室房间报警器响了"
              } else {
                location = "请注意查看，房间报警器响了"
              }
            } else {
              if(item.location) {
                if(item.location.place == '-1') {
                  location = item.location.building_name + '-' + item.location.floor_code + '-' + item.location.room_code + "卫生间报警器响了"
                } else {
                  location = item.location.building_name + '-' + item.location.floor_code + '-' + item.location.room_code + "报警器响了"
                }
              } else {
                location = "请注意查看，房间报警器响了"
              }
            }
            
            Push.create("请注意查看，房间报警器响了", {
              body: location,
              requireInteraction: true,
              // icon: './assets/qr_logo/lqr_logo.png',
              timeout: 60000,
            });
            // _that.Notification({
            //   title: '请注意查看，房间报警器响了',
            //   dangerouslyUseHTMLString: true,
            //   message: location,
            //   type: 'warning',
            //   customClass: "notificiation-wrap",
            //   // duration: 60000,
            //   onClose: () => {
            //     _that.audio.pause();
            //     _that.audio.currentTime = 0.0; 
            //   }
            // });
            _that.openMessageTips({
              title: location,
              message: '请注意查看，房间报警器响了',
              messageId: generateMixed(5)
            },() => {
              _that.audio.pause();
              _that.audio.currentTime = 0.0; 
              data.log_id && iotLogupdate("get", {id: data.log_id})
            })
          })
          if(!localStorage.getItem("syonoff") || localStorage.getItem("syonoff") == 'on') {
            setTimeout(()=>{
              _that.audio.src = audio1596;
              _that.audio.loop = true;
              _that.audio.play();
            }, 100);
          }
        }
        if(data.type == 3) {
          data.data.map(item => {
            let location = "";
            if(data.push_address == 'show_area') {
              
              if(item.status == "on"){
                if(item.devID == '5C0272FFFEA7C8DD01') {
                  location = "居家自理室房间门打开了"
                } else if(item.devID == "5C0272FFFEA60DB501") {
                  location = "介助介护培训室房间门打开了"
                } else {
                  location = "房间门打开了"
                }
              } else {
                if(item.devID == '5C0272FFFEA7C8DD01') {
                  location = "居家自理室房间门关闭了"
                } else if(item.devID == "5C0272FFFEA60DB501") {
                  location = "介助介护培训室房间门关闭了"
                } else {
                  location = "房间门关闭了"
                }
              }
            } else {
              if(item.location) {
                if(item.status == "on") {
                  location = item.location.building_name + '-' + item.location.floor_code + '-' + item.location.room_code + "房间门打开了"
                } else {
                  location = item.location.building_name + '-' + item.location.floor_code + '-' + item.location.room_code + "房间门关闭了"
                }
              } else {
                location = "房间门" + item.status == "on" ? "打开了" : "关闭了"
              }
            }
            
            Push.create(location, {
              body: location,
              requireInteraction: true,
              timeout: 60000,
            });
            // _that.Notification({
            //   title: location,
            //   dangerouslyUseHTMLString: true,
            //   message: location,
            //   type: 'warning',
            //   customClass: "notificiation-wrap",
            //   duration: 60000,
            // });
            _that.openMessageTips({
              title: location,
              message: location,
              messageId: generateMixed(5)
            }, () => {
              data.log_id && iotLogupdate("get", {id: data.log_id})
            })
          })
        }
        if(data.type == 4) {
          if(!localStorage.getItem("syonoff") || localStorage.getItem("syonoff") == 'on') {
            setTimeout(()=>{
              _that.audio.src = audio1596;
              _that.audio.loop = true;
              _that.audio.play();
            }, 100);
          }
          data.data.map(item => {
            let location = "";
            if(data.push_address == 'show_area') {
              location = "请注意查看，可燃气体打开了"
            } else {
              if(item.location) {
                location = item.location.building_name + '-' + item.location.floor_code + '-' + item.location.room_code + "可燃气体打开了"
              } else{
                location = "可燃气体打开了"
              }
            }
            Push.create("可燃气体报警", {
              body: location,
              requireInteraction: true,
              timeout: 60000,
            });
            _that.openMessageTips({
              title: location,
              message: '可燃气体报警',
              messageId: generateMixed(5)
            },() => {
              _that.audio.pause();
              _that.audio.currentTime = 0.0; 
              data.log_id && iotLogupdate("get", {id: data.log_id})
            })
          })
        }
        if(data.type == 5) {
          // setTimeout(()=>{
          //   _that.audio.src = audio1596;
          //   _that.audio.loop = true;
          //   _that.audio.play();
          // }, 100);
          data.data.map(item => {
            let location = "";
            if(data.push_address == 'show_area') {
              if(item.devID == "000D6F0014F6D98B01") {
                location = item.is_exists == 1 ? "请注意查看，居家自理室卫生间检测有人" : "请注意查看，居家自理室卫生间检测无人"
              }else {
                location = item.is_exists == 1 ? "请注意查看，检测有人" : "请注意查看，检测无人"
              }
            } else {
              if(item.location) {
                if(item.status == 1) {
                  location = item.location.building_name + '-' + item.location.floor_code + '-' + item.location.room_code + "请注意查看，检测有人"
                } else {
                  location = item.location.building_name + '-' + item.location.floor_code + '-' + item.location.room_code + "请注意查看，检测无人"
                }
              } else {
                location = item.status == 1 ? "请注意查看，检测有人" : "请注意查看，检测无人"
              }
            }
            Push.create("人体红外传感器报警", {
              body: location,
              requireInteraction: true,
              // icon: './assets/qr_logo/lqr_logo.png',
              timeout: 60000,
            });
            _that.openMessageTips({
              title: location,
              message: '人体红外传感器报警',
              messageId: generateMixed(5)
            }, () => {
              data.log_id && iotLogupdate("get", {id: data.log_id})
            })
            // _that.Notification({
            //   title: location,
            //   dangerouslyUseHTMLString: true,
            //   message: '人体红外传感器报警',
            //   type: 'warning',
            //   customClass: "notificiation-wrap",
            //   duration: 60000,
            //   // onClose: () => {
            //   //   _that.audio.pause();
            //   //   _that.audio.currentTime = 0.0; 
            //   // }
            // });
          })
          localStorage.setItem("toiletList", JSON.stringify(data.data));
          if(!data.is_test) {
            _that.toiletList = data.data;
          }
        }
        if(data.type == 6) {
          if(!localStorage.getItem("syonoff") || localStorage.getItem("syonoff") == 'on') {
            setTimeout(()=>{
              _that.audio.src = audio1596;
              _that.audio.loop = true;
              _that.audio.play();
            }, 100);
          }
          data.data.map(item => {
            let location = "";
            if(data.push_address == 'show_area') {
              location = "请注意查看，居家自理室烟雾报警";
            } else {
              if(item.location) {
                location = item.location.building_name + '-' + item.location.floor_code +'-' + item.location.room_code + "烟雾报警";
              } else {
                location = "请注意查看，烟雾报警"
              }
            }
            Push.create("烟雾报警", {
              body: location,
              requireInteraction: true,
              // icon: './assets/qr_logo/lqr_logo.png',
              timeout: 60000,
            });
            // _that.Notification({
            //   title: item.location ? item.location.building_name + '-' + item.location.floor_code +'-' + item.location.room_code + "烟雾报警" : "烟雾报警",
            //   dangerouslyUseHTMLString: true,
            //   message: '烟雾报警',
            //   type: 'warning',
            //   customClass: "notificiation-wrap",
            //   duration: 60000,
            //   onClose: () => {
            //     _that.audio.pause();
            //     _that.audio.currentTime = 0.0; 
            //   }
            // });
            _that.openMessageTips({
              title: location,
              message: '烟雾报警',
              messageId: generateMixed(5)
            },() => {
              _that.audio.pause();
              _that.audio.currentTime = 0.0; 
              data.log_id && iotLogupdate("get", {id: data.log_id})
            })
          })
        }
        if(data.type == 7) {
          data.data.map(item => {
            let location = "";
            if(data.push_address == "show_area") {
              if(item.percent == 100) {
                if(item.devID == '14B457FFFED01E9201' || item.devID == '14B457FFFECFFDAE01') {
                  location = "失能失智照护培训室房间窗帘打开" + item.percent + "%";
                } else if(item.devID == '14B457FFFED01A0301' || item.devID == '14B457FFFED01D6801') {
                  location = "居家自理室房间窗帘打开" + item.percent + "%";
                } else {
                  location = "窗帘打开" + item.percent + "%";
                }
              } else if(item.percent == 0) {
                if(item.devID == '14B457FFFED01E9201' || item.devID == '14B457FFFECFFDAE01') {
                  location = "失能失智照护培训室房间窗帘关闭" + item.percent + "%";;
                } else if(item.devID == '14B457FFFED01A0301' || item.devID == '14B457FFFED01D6801') {
                  location = "居家自理室房间窗帘关闭" + item.percent + "%";
                } else {
                  location = "窗帘关闭" + item.percent + "%";
                }
              }
            } else {
              if(item.location) {
                if(item.percent == 100) {
                  location = item.location.building_name + '-' + item.location.floor_code + '-' + item.location.room_code + "窗帘打开了"
                } else if(item.percent == 0){
                  location = item.location.building_name + '-' + item.location.floor_code + '-' + item.location.room_code + "窗帘关闭了"
                }
              } else {
                if(item.percent == 100) {
                  location = "窗帘打开了"
                } else if(item.percent == 0) {
                  location = "窗帘关闭了"
                }
              }
            }
            
            if(item.percent == 100 || item.percent == 0) {
              Push.create("窗帘", {
                body: location,
                requireInteraction: true,
                // icon: './assets/qr_logo/lqr_logo.png',
                timeout: 60000,
              });
              // _that.Notification({
              //   title: location,
              //   dangerouslyUseHTMLString: true,
              //   message: '窗帘',
              //   type: 'warning',
              //   customClass: "notificiation-wrap",
              //   duration: 60000,
              // });
              _that.openMessageTips({
                title: location,
                message: '窗帘',
                messageId: generateMixed(5)
              }, () => {
                data.log_id && iotLogupdate("get", {id: data.log_id})
              })
            } 
          })
          
        }
        if(data.type == 8) {
          if(!localStorage.getItem("syonoff") || localStorage.getItem("syonoff") == 'on') {
            setTimeout(()=>{
              _that.audio.src = audio1596;
              _that.audio.loop = true;
              _that.audio.play();
            }, 100);
          }
          data.data.map(item => {
            let location = "";
            if(data.push_address == "show_area"){
              location = "请注意查看，漏水报警了";
            } else {
              if(item.location) {
                location = item.location.building_name + '-' + item.location.floor_code +'-' + item.location.room_code + "漏水报警了"
              } else {
                location = "请注意查看，漏水报警了";
              }
            }
            Push.create("漏水报警", {
              body: location,
              requireInteraction: true,
              timeout: 60000,
            });
            _that.openMessageTips({
              title: location,
              message: '漏水报警',
              messageId: generateMixed(5)
            },() => {
              _that.audio.pause();
              _that.audio.currentTime = 0.0; 
              data.log_id && iotLogupdate("get", {id: data.log_id})
            })
          })
        }
        if(data.type == 10) {
          data.data.map(item => {
            let location = "";
            if(data.push_address == "show_area"){
              location = "请注意查看，安防报警";
            } else {
              if(item.location) {
                location = item.location.building_name + '-' + item.location.floor_code +'-' + item.location.room_code + "安防报警"
              } else {
                location = "请注意查看，安防报警";
              }
            }
            Push.create("安防报警", {
              body: location,
              requireInteraction: true,
              // icon: './assets/qr_logo/lqr_logo.png',
              timeout: 60000,
            });
            _that.openMessageTips({
              title: location,
              message: '安防报警',
              messageId: generateMixed(5)
            },() => {
              _that.audio.pause();
              _that.audio.currentTime = 0.0; 
              data.log_id && iotLogupdate("get", {id: data.log_id})
            })
            // _that.Notification({
            //   title: item.location ? item.location.building_name + '-' + item.location.floor_code +'-' + item.location.room_code + "安防报警" : "安防报警",
            //   dangerouslyUseHTMLString: true,
            //   message: '安防报警',
            //   customClass: "notificiation-wrap",
            //   type: 'warning',
            //   duration: 60000,
            //   onClose: () => {
            //     _that.audio.pause();
            //     _that.audio.currentTime = 0.0; 
            //   }
            // });
          })
          if(!localStorage.getItem("syonoff") || localStorage.getItem("syonoff") == 'on') {
            setTimeout(()=>{
              _that.audio.src = audio1596;
              _that.audio.loop = true;
              _that.audio.play();
            }, 100);
          }
        }
        if(data.type == '11') {
          const _this = _that;
          let location = "";
          if(data.push_address == 'show_area') {
            if(data.code == '6') {
              if(data.data.value == 0) {
                location = '';
              } else {
                location = '介助介护培训室床位无人'
              }
            } else if(data.code == '5'){
              if(data.data.value == 0) {
                location = '';
              } else {
                location = '居家自理室床位无人'
              }
            }
          } else {
            if(data.code == '6') {
              if(data.data.value == 0) {
                location = '';
              } else {
                location = '介助介护培训室床位无人'
              }
            } else if(data.code == '5'){
              if(data.data.value == 0) {
                location = '';
              } else {
                location = '居家自理室床位无人'
              }
            } else {
              if(data.place) {
                if(data.place.place == '0') {
                  location = (data.place.building_name && _that.toGB2312(data.place.building_name) || "") + '-' + data.place.floor_code + '-' + data.place.room_code + '-';
                } else {
                  location = (data.place.building_name && _that.toGB2312(data.place.building_name) || "") + '-' + data.place.floor_code + '-' + data.place.room_code + '-00' + data.place.place + '-';
                }
              } 
              if(data.data.value == 0) {
                location = "";
              } else {
                location = location + "床位无人"
              }
            }
          }
          
          if(location != "") {
            Push.create("床垫报警", {
              body: location,
              requireInteraction: true,
              timeout: 60000,
            });
            setTimeout(function(){
              _this.openMessageTips({
                title: location,
                message: '床垫报警',
                messageId: generateMixed(5)
              },() => {
                _that.audio.pause();
                _that.audio.currentTime = 0.0; 
                data.log_id && iotLogupdate("get", {id: data.log_id})
              })
            }, 0)
          }
          if(!localStorage.getItem("syonoff") || localStorage.getItem("syonoff") == 'on') {
            setTimeout(()=>{
              _that.audio.src = audio1596;
              _that.audio.loop = true;
              _that.audio.play();
            }, 100);
          }
        }
        if(data.type == '12') {
          const _this = _that;
          let location = "";
          if(data.push_address == 'show_area') {
            if(data.code =='6') {
              if(data.data.value == 1) {
                location = '介助介护培训室床位尿湿'
              } else {
                location = '';
              }
            } else if(data.code == '7'){
              if(data.data.value == 1) {
                location = '失能失智照护培训室床位尿湿'
              } else {
                location = '';
              }
            }
          } else {
            if(data.code =='6') {
              if(data.data.value == 1) {
                location = '介助介护培训室床位尿湿'
              } else {
                location = '';
              }
            } else if(data.code == '7'){
              if(data.data.value == 1) {
                location = '失能失智照护培训室床位尿湿'
              } else {
                location = '';
              }
            } else {
              if(data.place) {
                if(data.place.place == '0') {
                  location = (data.place.building_name && _that.toGB2312(data.place.building_name) || "") + '-' + data.place.floor_code + '-' + data.place.room_code + '-';
                } else {
                  location = (data.place.building_name && _that.toGB2312(data.place.building_name) || "") + '-' + data.place.floor_code + '-' + data.place.room_code + '-00' + data.place.place + '-';
                }
              } 
              if(data.data.value == 1) {
                location = location + "床位尿湿"
              } else {
                location = "";
              }
            }
          }
          if(location != "") {
            Push.create("床垫报警", {
              body: location,
              requireInteraction: true,
              timeout: 60000,
            });
            setTimeout(function(){
              _this.openMessageTips({
                title: location,
                message: '床垫报警',
                messageId: generateMixed(5)
              },() => {
                _that.audio.pause();
                _that.audio.currentTime = 0.0; 
                data.log_id && iotLogupdate("get", {id: data.log_id})
              })
            }, 0)
          }
          if(!localStorage.getItem("syonoff") || localStorage.getItem("syonoff") == 'on') {
            setTimeout(()=>{
              _that.audio.src = audio1596;
              _that.audio.loop = true;
              _that.audio.play();
            }, 100);
          }
        }
    }
  }
}
